﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Display.CopsBanditsUI {
    import flash.display.*;
    import Events.*;
    import org.aswing.*;
    import Classes.*;
    import Modules.bandits.*;
    import flash.text.*;
    import Display.aswingui.*;

    public class BanditsPanel extends JPanel {

        public static const BANDITS_PER_PAGE:int = 4;

        protected var m_bandits:Array;
        protected var m_headerPanel:JPanel;
        protected var m_bodyPanel:JPanel;
        protected var m_footerPanel:JPanel;
        protected var m_shelf:JPanel;
        protected var m_banditTextField:TextField;
        protected var m_banditTextFormat:TextFormat;

        public function BanditsPanel(){
            super(new SoftBoxLayout(SoftBoxLayout.Y_AXIS, 0, SoftBoxLayout.TOP));
            this.init();
            Global.stage.addEventListener(GenericObjectEvent.REFRESH_BANDIT_INFO, this.onUpdateBanditText, false, 0, true);
        }
        protected function init():void{
            this.m_banditTextField = new TextField();
            this.m_banditTextField.text = "";
            this.m_banditTextField.embedFonts = true;
            this.m_banditTextField.autoSize = TextFieldAutoSize.LEFT;
            this.m_banditTextField.multiline = true;
            this.m_banditTextField.wordWrap = true;
            this.m_banditTextField.antiAliasType = AntiAliasType.ADVANCED;
            this.m_banditTextField.gridFitType = GridFitType.PIXEL;
            this.m_banditTextFormat = new TextFormat(EmbeddedArt.DEFAULT_FONT_NAME_BOLD, 14, EmbeddedArt.darkBlueTextColor, false, false, false, null, null, TextFormatAlign.LEFT);
            this.m_bandits = BanditManager.getBanditDefinitions();
            while ((this.m_bandits.length % BANDITS_PER_PAGE) != 0) {
                this.m_bandits.push(new BanditData(null));
            };
            this.makeBackground();
            ASwingHelper.setEasyBorder(this, 0, 0);
            this.m_headerPanel = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.CENTER);
            this.m_bodyPanel = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.CENTER);
            this.m_footerPanel = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.CENTER);
            this.m_footerPanel.addChild(this.m_banditTextField);
            this.m_banditTextField.x = 10;
            this.m_banditTextField.y = 5;
            this.setPreferredWidth(671);
            this.setPreferredHeight(390);
            this.append(ASwingHelper.verticalStrut(8));
            this.append(this.makeBodyPanel());
            this.append(ASwingHelper.verticalStrut(5));
            this.append(this.makeFooterPanel());
            this.append(ASwingHelper.verticalStrut(15));
            ASwingHelper.prepare(this);
        }
        protected function makeBackground():void{
            var _local1:DisplayObject = (new (CopsDialog.assetDict["inner_undertab"])() as DisplayObject);
            ASwingHelper.setBackground(this, _local1);
        }
        protected function makeBodyPanel():JPanel{
            this.m_shelf = new BanditsScrollingList(this.m_bandits, BanditsCellFactory, 0, BANDITS_PER_PAGE, 1);
            ASwingHelper.prepare(this.m_shelf);
            this.m_bodyPanel.append(this.m_shelf);
            return (this.m_bodyPanel);
        }
        protected function makeFooterPanel():JPanel{
            var _local1:JPanel = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.CENTER);
            ASwingHelper.setBackground(this.m_footerPanel, (new (CopsDialog.assetDict["police_innerBorder"])() as DisplayObject));
            var _local2:int = ((this.m_shelf)!=null) ? (this.m_shelf as BanditsScrollingList).getScrollWidth() : (BanditsCell.BANDIT_CELL_WIDTH * BANDITS_PER_PAGE);
            ASwingHelper.setForcedWidth(this.m_footerPanel, _local2);
            ASwingHelper.setForcedHeight(this.m_footerPanel, 65);
            _local1.append(this.m_footerPanel);
            return (_local1);
        }
        public function onUpdateBanditText(_arg1:GenericObjectEvent):void{
            if (_arg1.obj){
                this.m_banditTextField.text = String(_arg1.obj);
                this.m_banditTextField.width = (this.m_footerPanel.getPreferredWidth() - 20);
                this.m_banditTextField.setTextFormat(this.m_banditTextFormat);
                ASwingHelper.prepare(this.m_footerPanel);
            };
        }

    }
}//package Display.CopsBanditsUI 
